Comparing the bikeways by type with the highway mileage for each city
This analysis calculates and compares roadway lane miles and bikeway facility miles across Utah municipalities using spatial data from the Utah Geospatial Resource Center (UGRC).
We use EPSG:3566 (NAD83(HARN) / Utah North) projection, which uses US survey feet as the base unit. This projection is appropriate for statewide analysis in Utah and ensures accurate distance calculations.
Show the code
# Set Project CRSPROJECT_CRS="EPSG:3566"# Set tmap mode to interactivetmap::tmap_mode("view")
ℹ tmap modes "plot" - "view"
ℹ toggle with `tmap::ttm()`
3 Read Data from UGRC
All spatial datasets are downloaded from UGRC’s ArcGIS REST services. To improve performance and enable offline work, the data is cached locally as GeoDatabase files. The code checks if local copies exist before downloading.
Show the code
# set data folderdir_data<-"_data"fs::dir_create(dir_data)# Create a directory if it doesnt exist
3.1 Utah City Boundaries
Municipal boundaries are used to aggregate roadway and bikeway data by city. These boundaries represent the legal limits of incorporated municipalities in Utah.
Show the code
# Define pathspath_ut_cities<-file.path(dir_data, "UGRC", "UtahMunicipalBoundaries.gdb")# Download if not existsif(!fs::file_exists(path_ut_cities)){# Read data using arcgis packagesf_ut_cities<-arcgislayers::arc_read("https://services1.arcgis.com/99lidPhWCzftIe9K/ArcGIS/rest/services/UtahMunicipalBoundaries/FeatureServer/0", crs =PROJECT_CRS)|>janitor::clean_names()# Write to a GeoDatabasesf_ut_cities|>sf::st_write(path_ut_cities, layer ="UtahMunicipalBoundaries", append =FALSE)}else{# Read from local copysf_ut_cities<-sf::st_read(path_ut_cities)|>sf::st_transform(PROJECT_CRS)}
Reading layer `UtahMunicipalBoundaries' from data source
`D:\GitHub\GIS-Bikeway-by-City\_data\UGRC\UtahMunicipalBoundaries.gdb'
using driver `OpenFileGDB'
Simple feature collection with 259 features and 17 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 934991.8 ymin: 6077738 xmax: 2272474 ymax: 7898798
Projected CRS: NAD83 / Utah Central (ftUS)
County boundaries are used to aggregate roadway and bikeway data for unincorporated areas in Utah.
Show the code
# Define pathspath_ut_counties<-file.path(dir_data, "UGRC", "UtahCountyBoundaries.gdb")# Download if not existsif(!fs::file_exists(path_ut_counties)){# Read data using arcgis packagesf_ut_counties<-arcgislayers::arc_read("https://services1.arcgis.com/99lidPhWCzftIe9K/ArcGIS/rest/services/UtahCountyBoundaries/FeatureServer/0", crs =PROJECT_CRS)|>janitor::clean_names()# Write to a GeoDatabasesf_ut_counties|>sf::st_write(path_ut_counties, layer ="UtahCountyBoundaries", append =FALSE)}else{# Read from local copysf_ut_counties<-sf::st_read(path_ut_counties)|>sf::st_transform(PROJECT_CRS)}
Reading layer `UtahCountyBoundaries' from data source
`D:\GitHub\GIS-Bikeway-by-City\_data\UGRC\UtahCountyBoundaries.gdb'
using driver `OpenFileGDB'
Simple feature collection with 29 features and 13 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 895000.7 ymin: 6076316 xmax: 2358017 ymax: 7905124
Projected CRS: NAD83 / Utah Central (ftUS)
The Utah Roads dataset contains all roadway centerlines statewide, including the number of through lanes for each road segment. This forms the basis for calculating road lane miles.
Show the code
# Define pathspath_ut_roads<-file.path(dir_data, "UGRC", "UtahRoads.gdb")# Download if not existsif(!fs::file_exists(path_ut_roads)){# Read data using arcgis packagesf_ut_roads<-arcgislayers::arc_read("https://services1.arcgis.com/99lidPhWCzftIe9K/ArcGIS/rest/services/UtahRoads/FeatureServer/0", crs =PROJECT_CRS)|>janitor::clean_names()# Write to a GeoDatabasesf_ut_roads|>sf::st_write(path_ut_roads, layer ="UtahRoads", append =FALSE)}else{# Read from local copysf_ut_roads<-sf::st_read(path_ut_roads)|>sf::st_transform(PROJECT_CRS)}
Reading layer `UtahRoads' from data source
`D:\GitHub\GIS-Bikeway-by-City\_data\UGRC\UtahRoads.gdb' using driver `OpenFileGDB'
Simple feature collection with 410604 features and 86 fields
Geometry type: MULTILINESTRING
Dimension: XY
Bounding box: xmin: 895206.4 ymin: 6071653 xmax: 2356671 ymax: 7904448
Projected CRS: NAD83 / Utah Central (ftUS)
The Bikeways dataset contains all existing bicycle facilities in Utah. Each segment has two facility type attributes (facility1 and facility2) representing the bicycle facility in each direction of travel.
Show the code
# Define pathspath_ut_bikeways<-file.path(dir_data, "UGRC", "Bikeways.gdb")# Download if not existsif(!fs::file_exists(path_ut_bikeways)){# Read data using arcgis packagesf_ut_bikeways<-arcgislayers::arc_read("https://services1.arcgis.com/99lidPhWCzftIe9K/ArcGIS/rest/services/Bikeways/FeatureServer/0", crs =PROJECT_CRS)|>janitor::clean_names()# Write to a GeoDatabasesf_ut_bikeways|>sf::st_write(path_ut_bikeways, layer ="Bikeways", append =FALSE)}else{# Read from local copysf_ut_bikeways<-sf::st_read(path_ut_bikeways)|>sf::st_transform(PROJECT_CRS)}
Reading layer `Bikeways' from data source
`D:\GitHub\GIS-Bikeway-by-City\_data\UGRC\Bikeways.gdb' using driver `OpenFileGDB'
Simple feature collection with 101693 features and 12 fields
Geometry type: MULTILINESTRING
Dimension: XY
Bounding box: xmin: 896123 ymin: 6076384 xmax: 2356440 ymax: 7904448
Projected CRS: NAD83 / Utah Central (ftUS)
tmap::qtm(sf_ut_cities, col ="blue", fill =NULL, size =1)+tmap::qtm(sf_ut_counties, col ="red", fill =NULL, size =2)
Show the code
# Create combined municipal boundaries including unincorporated areassf_ut_municipal<-dplyr::bind_rows(# Add incorporated citiessf_ut_cities|>dplyr::select(Name =name),# Add unincorporated county areassf_ut_counties|>dplyr::mutate(# Convert county name to proper case and add "(Unincorporated)" Name =paste0(stringr::str_to_title(name), " County (Unincorporated)"))|>dplyr::select(Name)|># Remove areas that overlap with citiessf::st_difference(sf_ut_cities|>sf::st_union()))
Warning: attribute variables are assumed to be spatially constant throughout
all geometries